import os
import glob

# 定义目标目录和文件格式
target_dir = '../data/test/'
file_pattern = os.path.join(target_dir, '*_res.png')

# 获取所有匹配文件
res_files = glob.glob(file_pattern)

# 遍历删除文件
for file_path in res_files:
    try:
        os.remove(file_path)
        print(f"已删除文件: {file_path}")
    except Exception as e:
        print(f"删除失败 {file_path}: {str(e)}")

print(f"共删除 {len(res_files)} 个文件")
